<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/axios.min.js"></script>
    <script src="js/vue.min.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="ele-2.15.7/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="ele-2.15.7/index.js"></script>
</head>
<body>

<style>

    .text {
        font-size: 14px;
    }

    .item {
        padding: 18px 0;
    }

    .box-card {
        width: 100%;
        height: 200px;
        margin: auto;
        margin-top:30px ;
    }

    .btn-add {
        float: right;
    }



    .btn-add{
        font-size: 14px;

    }
    .operate-container{
        height: 59px;
    }

    /*.pagerstyle{*/
    /*    margin-left: 1247px;*/
    /*}*/

    .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }
    .avatar-uploader .el-upload:hover {
        border-color: #409EFF;
    }
    .avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px;
        text-align: center;
    }
    .avatar {
        width: 178px;
        height: 178px;
        display: block;
    }

    .container-filter{
        height: 140px;
    }

    .operate-container{
        height: 60px;
        margin-bottom:20px;
    }


</style>

<div id="app">

    <el-card class="box-card operate-container " shadow="never">
        <i class="el-icon-tickets"></i>
        <span>数据列表</span>
        <el-button class="btn-add" size="mini" >
            <span>添加</span>
        </el-button>
    </el-card>

    <el-table
            :header-cell-style="{'text-align':'center'}"
            :cell-style="{'text-align':'center'}"
            stripe
              class="el-table--border  "
              :data="tableData.data">
        <el-table-column prop="detailid" label="编号"></el-table-column>
        <el-table-column prop="cause" label="原因类型"></el-table-column>
        <el-table-column prop="status" label="是否可用" width="130px">
            <template slot-scope="scope">
                <el-switch
                        v-model="status">
                </el-switch>
            </template>
        </el-table-column>
        <el-table-column prop="createtime" label="添加时间" width="269">
            <template slot-scope="scope">
                {{ scope.row.createtime | formatTimer }}
            </template>
        </el-table-column>
        <el-table-column label="操作">
            <template slot-scope="scope">
                <el-button
                        size="mini"
                        @click="">编辑
                </el-button>

                <el-button
                        size="mini"
                        type="danger"
                        @click="">删除
                </el-button>

            </template>
        </el-table-column>
    </el-table>

    <el-footer style="text-align: right">
        <el-pagination :page-size="pageSize" @current-change="query" @size-change="sizeChange"
                       background :page-sizes="[10,15,20]"
                       layout="total,sizes,prev, pager,next,jumper"
                       :total="tableData.total"
                       :current-page.sync="tableData.page">
        </el-pagination>
    </el-footer>
</div>
</body>
<script>
    var v = new Vue({
        el : "#app",
        data : {
            detailid : "",
            cause : "",
            rid : "",
            status : "",
            createtime : null,
            //表格数据
            tableData: {page:1},
            pageSize: 10,
        },
        created() {
            this.query(1);

        },
        methods : {
            query(page) {
                axios.get("ReturnReasonServlet.s",{
                    params: {
                        detailid : this.detailid,
                        cause : this.cause,
                        rid : this.rid,
                        status: this.status,
                        returntime: this.returntime  ? this.returntime.toLocaleDateString().replace(/\//g, '-') : null,
                        currentPage : page, //当前页数
                        pageSize: this.pageSize //每页显示条目个数
                    }
                }).then(res=>{
                    this.tableData = res.data;
                    this.tableData.page = page;
                })
            },

            sizeChange(page){
                this.pageSize =page;
                this.query(1);
            }

        },
        filters: {
            formatTimer: function (value) {
                let date = new Date(value);
                let y = date.getFullYear();
                let MM = date.getMonth() + 1;
                MM = MM < 10 ? "0" + MM : MM;
                let d = date.getDate();
                d = d < 10 ? "0" + d : d;
                let h = date.getHours();
                h = h < 10 ? "0" + h : h;
                let m = date.getMinutes();
                m = m < 10 ? "0" + m : m;
                let s = date.getSeconds();
                s = s < 10 ? "0" + s : s;
                return y + "-" + MM + "-" + d + " " + h + ":" + m;
            }
        },
    })
</script>

</html>